// CyberX.cpp

#include "stdafx.h"

#include "..\Core\Singleton.h"
//#include "..\CyberXMain\typeset.h"
#include "..\CyberXMain\ICyberXMain.h"

#include "ICyberX.h"

//////////////////////////////////////////////////////////////////////////
class CCyberX : public ICyberX, public Singleton<CCyberX>
{
public:
	CCyberX(void);
	virtual ~CCyberX();

	// interface of ICyberX
	virtual bool Initialize(HWND hWnd, int nWidth, int nHeight, bool bWindow);
	virtual void UpdateFrame(unsigned long ulDeltaTime);
};

//////////////////////////////////////////////////////////////////////////
CCyberX::CCyberX(void)
{

}

CCyberX::~CCyberX()
{
}

//////////////////////////////////////////////////////////////////////////
namespace
{
	CCyberX* s_pCyberX = NULL;
//	ICameraPtr s_pCamera;
}

//////////////////////////////////////////////////////////////////////////
bool CCyberX::Initialize(HWND hWnd, int nWidth, int nHeight, bool bWindow)
{
	ICyberXMain::GetSingleton()->Initialize(hWnd, nWidth, nHeight, bWindow);
// 	s_pCamera = ICyberXMain::GetSingleton()->CreateCamera();
// 	s_pCamera->Setup(50.0f, 50.0f, 50.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
// 	s_pCamera->SetViewport(nWidth, nHeight);
// 	s_pCamera->SetFarPlane(2000.0f);
// 	s_pCamera->SetNearPlane(1.0f);
	//s_pCamera->SetFov(D3DX_PI / 4);
	return true;
}

void CCyberX::UpdateFrame(unsigned long ulDeltaTime)
{
	ICyberXMain::GetSingleton()->Process();
	ICyberXMain::GetSingleton()->RenderBegin();
	ICyberXMain::GetSingleton()->Render();
	ICyberXMain::GetSingleton()->RenderEnd();
	return;
}

//////////////////////////////////////////////////////////////////////////
// interface of ICyberX
void ICyberX::Create(void)
{
	if (NULL == s_pCyberX)
	{
		s_pCyberX = new CCyberX;
	}
}

ICyberX* ICyberX::Get(void)
{
	return static_cast<ICyberX*>(CCyberX::GetSingletonPtr());
}